<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>部门更新</title>
<s:include value="/app_common/common.jsp"></s:include>
<!-- 表单验证start -->
<script src="<s:property value='webctx'/>/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="<s:property value='webctx'/>/libs/js/form/validation.js" type="text/javascript"></script>
<!-- 表单验证end -->
</head>
<body>
	<div class="box1" panelWidth="500">
		<form name="form2" id="form2" method="post" target="frmright">
			<s:if test="%{#parameters.id!=null}">
				<s:hidden name="select.id" value="%{#parameters.id}"></s:hidden>
			</s:if>
			<table class="tableStyle" formMode="line">
				<tr>
					<th colspan="4">下拉模板信息更新</th>
				</tr>
				<tr>
					<td>类型：</td>
					<td>
						<select class="validate[required]" prompt="请选择" name="select.type" selectedValue="<s:property value='#parameters.type'/>"  url="<s:property value='webctx'/>/select/select_querySelectTypeAll.action"></select><span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td>值：</td>
					<td><input type="text" id="value" name="select.value" value="<s:property value="#parameters.value" />" class="validate[required,length[0,20]]"/><span class="star">*</span></td>
				</tr>
				<tr>
					<td>键：</td>
					<td><input  type="text" id="key" name="select.key" value="<s:property value="#parameters.key" />" class="validate[required]"><span class="star">*</span></td>
				</tr>
				<tr>
					<td colspan="2">
					<input type="button" onclick="checkSubmit()" value="提交" />&nbsp;</td>
				</tr>
			</table>
		</form>
	</div>
</body>
<script type="text/javascript">
	var status = "<s:property value='#parameters.status' />";
	function checkSubmit(){
		var actionUrl;
		var valid = $("#form2").validationEngine({returnIsValid: true});
		if(!valid){
			return false;
		}
		if(status==0){
			actionUrl = webctx+"/select/select_updateSelectById.action";
		}else{
			actionUrl = webctx+"/select/select_insertSelectById.action";
		}
		var actionData = $("#form2").serialize();
		$.ajax({
			url:actionUrl,
			data:actionData,
			type : "post",
			cache : false,
			dataType : 'text',
			success : function(data) {
				alert(data);
				if(data.indexOf('失败')!=-1||data.indexOf('存在')!=-1){
					return false;
				}
				top.frmright.window.document.form1.submit();
				top.Dialog.close();
			}
		});
	}
</script>
</html>